<!--{template /module/admin/view/head}-->
<style>
.record-item {position:relative;}
.record-item .float {position:absolute; top:0; right:0; text-align:right;}
</style>
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<p class="text">{lang note.record_view.view.header}</p>
				</div>
				<div class="widget-content">
				<table class="table" id="tbl_records">
					<!--{if $_var[page] < 2}-->
					<tr>
			            <td width="200" valign="top">
			            	<p>
			            		<strong>{lang note.record_edit.view.username.label}:</strong>{$record[USERNAME]}
			            	</p>
			            	
			            	<!--{if $record[DEPARTMENT]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.department.label}:</strong><br/>{$record[DEPARTMENT]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $record[PLACE]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.place.label}:</strong><br/>{$record[PLACE]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $record[EMAIL]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.email.label}:</strong><br/>{$record[EMAIL]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $record[CONNECT]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.phone.label}:</strong><br/>{$record[CONNECT]}
			            	</p>
			            	<!--{/if}-->
			            </td>
			            <td valign="top" style="background:#fff;">
			            	<p>
			            		<strong>[{if $record['ISOPEN'] == 1}{lang admin.operation.open}{else}{lang admin.operation.hide}{/if}] {$record[TITLE]}({$record[NOTENAME]})</strong>
			            	</p>
			            	
			            	<p>{$record[CONTENT]}</p>
			            	
				            <!--{if $record[REPLY]}-->
				            <hr/>
				            <div class="reply">
					            <p class="title">{lang note.record_edit.view.reply.label}:</p>
					            {$record[REPLY]}
				            </div>
				            <!--{/if}-->
			            </td>
			        </tr>
					<!--{/if}-->
					<!--{loop $children $_loop $item}-->
					<tr>
						<td width="200" valign="top">
							<p>
			            		<strong>{lang note.record_edit.view.username.label}:</strong>{$item[USERNAME]}
			            	</p>
			            	
			            	<!--{if $item[DEPARTMENT]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.department.label}:</strong><br/>{$item[DEPARTMENT]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $item[PLACE]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.place.label}:</strong><br/>{$item[PLACE]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $item[EMAIL]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.email.label}:</strong><br/>{$item[EMAIL]}
			            	</p>
			            	<!--{/if}-->
			            	
			            	<!--{if $item[CONNECT]}-->
			            	<p>
			            		<strong>{lang note.record_edit.view.phone.label}:</strong><br/>{$item[CONNECT]}
			            	</p>
			            	<!--{/if}-->
						</td>
						<td valign="top" style="background:#fff;">
							<div class="record-item">
								<p>
				            		<strong>{$item[TITLE]}</strong>
				            	</p>
				            	<p class="float">
				            		{lang note.record_view.view.reply.sort} <span class="f16">{echo $start + $_loop + 1;}</span> {lang note.record_view.view.reply.floor}
				            		&nbsp;
				            		<a href="javascript:void(null);" class="btn btn-mini btn-primary btn-edit"  title="{$item[TITLE]}" data="{$item[NOTE_RECORDID]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
									<a href="javascript:void(null);" class="btn btn-mini btn-delete" title="{$item[TITLE]}" data="{$item[NOTE_RECORDID]}" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
				            	</p>
			            	</div>
			            	
			            	<p>{$item[CONTENT]}</p>
						</td>
					</tr>
					<!--{/loop}-->
					<!--{if $count > 0}-->
			        <tr>
						<td colspan="2">
							{$pager}
						</td>
					</tr>
					<!--{/if}-->
			        <tr>
						<td colspan="2">
							<button type="submit" name="btnAdd" id="btn_add_record" class="btn btn-small" {$dispatches[operations][add]}>{lang note.record_view.view.operation.add}</button>
							<button type="button" name="btnBack" class="btn btn-small" onclick="javascript:location.href='{$ADMIN_SCRIPT}/note/record&page={$_var[gp_ppage]}&psize={$_var[gp_ppsize]}{$search[querystring]}';">{lang admin.operation.go.back}</button>
						</td>
					</tr>
				</table>
				<form id="frm_record" name="frmRecord" method="post" action="{$ADMIN_SCRIPT}/note/record/_view&do=reply&id={$_var[gp_id]}&ppage={$_var[gp_ppage]}&ppsize={$_var[gp_ppsize]}{$search[querystring]}" onsubmit="javascript:return check_form(this);">
				<input type="hidden" name="formsubmit" value="yes" />
			    <div class="well widget" id="tbl_add_record" style="display:none;">
					<div class="widget-header">
						<p class="text">* {lang admin.validate.require}</p>
					</div>
					<div class="widget-content" >
						<fieldset>
							<!--{if $cnote[GUEST] == 0}-->
							<label>{lang note.record_edit.view.username.label} *</label>
							<input type="text" class="input-large" name="txtUserName" placeholder="{lang note.record_edit.view.username.placeholder}..." maxlength="20"/> 
							<span class="help-inline">{lang note.record_edit.view.username.tips}</span>
							<!--{/if}-->
							
							<label>{lang note.record_edit.view.title.label} *</label>
							<input type="text" class="input-large" name="txtTitle" placeholder="{lang note.record_edit.view.title.placeholder}..." maxlength="50" value="{lang note.record_view.view.reply.prev}{$record[TITLE]}"/> 
							<span class="help-inline">{lang note.record_edit.view.title.tips}</span>
							
							<!--{if $cnote[NEEDS][department] + 0 > 0}-->
							<label>{lang note.record_edit.view.department.label} *</label>
							<input type="text" class="input-large" name="txtDepartment" placeholder="{lang note.record_edit.view.department.placeholder}..."  maxlength="50"  value="{$record[DEPARTMENT]}"  /> 
							<span class="help-inline">{lang note.record_edit.view.department.tips}</span>
							<!--{/if}-->
							
							<!--{if $cnote[NEEDS][place] + 0 > 0}-->
							<label>{lang note.record_edit.view.place.label} *</label>
							<input type="text" class="input-xlarge"name="txtPlace" placeholder="{lang note.record_edit.view.place.placeholder}..."  size="40" maxlength="100" value="{$record[PLACE]}" /> 
							<span class="help-inline">{lang note.record_edit.view.place.tips}</span>
							<!--{/if}-->
							
							<!--{if $cnote[NEEDS][email] + 0 > 0}-->
							<label>{lang note.record_edit.view.email.label} *</label>
							<input type="text" class="input-xlarge" name="txtEmail" placeholder="{lang note.record_edit.view.email.placeholder}..."  maxlength="100"  value="{$record[EMAIL]}" /> 
							<span class="help-inline">{lang note.record_edit.view.email.tips}</span>
							<!--{/if}-->
							
							<!--{if $cnote[NEEDS][connect] + 0 > 0}-->
							<label>{lang note.record_edit.view.phone.label} *</label>
							<input type="text" class="input-medium"name="txtConnect" placeholder="{lang note.record_edit.view.phone.placeholder}..."  maxlength="50" value="{$record[CONNECT]}" /> 
							<span class="help-inline">{lang note.record_edit.view.phone.tips}</span>
							<!--{/if}-->
							
							<label>{lang note.record_edit.view.content.label} *</label>
							<textarea class="span8" rows="4" cols="45" name="txtContent"></textarea>
							<span class="help-inline">{lang note.record_edit.view.content.tips}</span>

						</fieldset>
						
						<hr/>
						
						<fieldset>
							<button type="submit" name="btnSubmit" id="btn_submit" class="btn btn-small btn-primary" {$dispatches[operations][add]}>{lang admin.operation.submit}</button>
							<button type="button"  name="btnCancel" id="btn_cancel" class="btn btn-small">{lang admin.operation.cancel}</button>
						</fieldset>
					</div>
				</div>
				</form>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
var cnote = {
	GUEST:{$cnote[GUEST]},
	BEGINDATE: '{$cnote[BEGINDATE]}', 
	ENDDATE: '{$cnote[ENDDATE]}', 
	NEEDS: {
		department: {echo $cnote[NEEDS][department] + 0;}, 
		place: {echo $cnote[NEEDS][place] + 0;}, 
		email: {echo $cnote[NEEDS][email] + 0;}, 
		connect: {echo $cnote[NEEDS][connect] + 0;} 
	}
};

function check_form(frm){
	if(cnote.GUEST == 0 && frm.txtUserName.value.trim().length == 0){
		$(frm.txtUserName).next('.help-inline').css('color', 'red');
    	frm.txtUserName.focus();
    	return false;
    }
    
    if(frm.txtTitle.value.trim().length == 0){
    	$(frm.txtTitle).next('.help-inline').css('color', 'red');
    	frm.txtTitle.focus();
    	return false;
    }
    
    if(cnote.NEEDS.department && frm.txtDepartment.value.trim().length == 0){
    	$(frm.txtDepartment).next('.help-inline').css('color', 'red');
    	frm.txtDepartment.focus();
    	return false;
    }
    
    if(cnote.NEEDS.place && frm.txtPlace.value.trim().length == 0){
    	$(frm.txtPlace).next('.help-inline').css('color', 'red');
    	frm.txtPlace.focus();
    	return false;
    }
    
    if(cnote.NEEDS.email && frm.txtEmail.value.trim().length == 0){
    	$(frm.txtEmail).next('.help-inline').css('color', 'red');
    	frm.txtEmail.focus();
    	return false;
    }
    
    if(cnote.NEEDS.email && !frm.txtEmail.value.trim().isEmail()){
    	$(frm.txtEmail).next('.help-inline').css('color', 'red');
    	frm.txtEmail.focus();
    	return false;
    }
    
    if(cnote.NEEDS.connect && frm.txtConnect.value.trim().length == 0){
    	$(frm.txtConnect).next('.help-inline').css('color', 'red');
    	frm.txtConnect.focus();
    	return false;
    }
    
    if(frm.txtContent.value.trim().length == 0){
    	$(frm.txtContent).next('.help-inline').css('color', 'red');
    	frm.txtContent.focus();
    	return false;
    }

    return true;
}

$(function(){
	$('fieldset input,textarea,select').blur(function(){
		$(this).next('.help-inline').css('color', '#333');
	});
	
	$('#tbl_records .btn-edit').click(function(){
		var recordid = $(this).attr('data');
		
		$.getJSON('{$ADMIN_SCRIPT}/note/record/_json&id=' + recordid, {}, function(json){
	 		var frm = $('#frm_record').get(0);
	 		
	 		frm.action = '{$ADMIN_SCRIPT}/note/record/_view&do=edit&recordid=' + recordid + '&page={$_var[page]}&id={$_var[gp_id]}&ppage={$_var[gp_ppage]}&ppsize={$_var[gp_ppsize]}{$search[querystring]}';
	 		
	 		$("#tbl_add_record input[name='txtUserName']").val(json.USERNAME);
	 		$("#tbl_add_record input[name='txtTitle']").val(json.TITLE);
	 		$("#tbl_add_record input[name='txtDepartment']").val(json.DEPARTMENT);
	 		$("#tbl_add_record input[name='txtPlace']").val(json.PLACE);
	 		$("#tbl_add_record input[name='txtEmail']").val(json.EMAIL);
	 		$("#tbl_add_record input[name='txtConnect']").val(json.CONNECT);
	 		$("#tbl_add_record textarea[name='txtContent']").val(json.CONTENT);
	 		
	 		$('#tbl_add_record').show();
			$('#btn_submit').focus();
	 	});
	});
	
	$('#tbl_records .btn-delete').click(function(){
  		var recordid = $(this).attr('data');
  		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
  		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang note.record_view.view.operation.delete.message}</p>' + tempHTML, callback:function(){
  			$('#modal_dialog .btn-primary').click(function(){
  				location.href = '{$ADMIN_SCRIPT}/note/record/_view&do=delete&recordid=' + recordid + '&page={$_var[page]}&id={$_var[gp_id]}&ppage={$_var[gp_ppage]}&ppsize={$_var[gp_ppsize]}{$search[querystring]}';
  			});
  		}});
  	});

	$('#btn_add_record').click(function(){
		$('#tbl_add_record').show();
		$('#btn_submit').focus();
	});
	
	$('#btn_cancel').click(function(){
		$('#tbl_add_record').hide();
	});
});
    
</script>
<!--{template /module/admin/view/foot}-->